﻿#include "projHeader.h"

	extern LPCWSTR RailsV; //вертикальные рельсы
	extern LPCWSTR RailsH; //горизонтальные рельсы
	extern LPCWSTR RailsX;   //диагональные рельсы
	extern LPCWSTR LeftCorner;  //левый нижний угол
	extern LPCWSTR Space;
	extern LPCWSTR Scepka;
	extern LPCWSTR Povorot;
	extern LPCWSTR RailsV1;
	extern LPCWSTR Vagon;
	extern LPCWSTR RailsX1;
	extern LPCWSTR RailsH1;
	extern LPCWSTR Povorot1;
	extern LPCWSTR Povorot2;
	extern LPCWSTR Povorot3;

	

SubWay::SubWay ()
{
	
}

void SubWay::ShowRailroad(int x, int y, char position)
	{
		WORD MyAttribTrain = FOREGROUND_BLUE | BLUE_FONT | FOREGROUND_INTENSITY;
		WORD MyAttribRails = WHITE_FONT;
		WORD MyAttribRails1 = 15 + 0;


		if(position == (char)"V")
		{
		WriteChars(x,y, Space,MyAttribRails, 4);
		WriteChars(x + 5,y,RailsV,MyAttribRails1, 1);
		WriteChars(x + 6,y,RailsV,MyAttribRails1, 1);
		WriteChars(x + 8,y, Space,MyAttribRails, 4);
		}
		else 
			if(position == (char)"X")
			{
				WriteChars(x,y, Space,MyAttribRails, 4);
				WriteChars(x + 5,y,RailsX,MyAttribRails1, 1);
				WriteChars(x + 6,y,RailsX,MyAttribRails1, 1);
				WriteChars(x + 8,y, Space,MyAttribRails, 4);
			}
			else 
			if(position == (char)"H")
			{
				for(int i = y + 1; i < y + 4; i++)
				{
					WriteChars(x,i, Space,MyAttribRails, 1);
				}
				WriteChars(x,y + 4,RailsH,MyAttribRails1, 1);
				WriteChars(x,y + 5,RailsH,MyAttribRails1, 1);
				for(int i = y  + 6; i < y + 9; i++)
				{
					WriteChars(x,i, Space,MyAttribRails, 1);
				}
			}
			
			WriteChars(135,72,Povorot,MyAttribRails1, 1);// povorot po 35_mu marshrutu
			WriteChars(136,71,Povorot,MyAttribRails1, 1);// povorot po 36_mu marshrutu
			WriteChars(136,72,RailsV,MyAttribRails1, 1);// povorot po 36_mu marshrutu
			
	}

	void SubWay::ShowPlatform(int visota, int shirina, int x, int y)
	{
		WORD MyAttribPlatform = PURPLE_FONT;

		COORD c;
		c.X = x;
		c.Y = y;
		
		for(int i = 0; i < visota;i++)
		{
			//SetColor(LightCyan,LightCyan);
			WriteChars(x, ++y, Space,MyAttribPlatform, shirina);

		}
	}

	void SubWay::ShowTrain(int x, int y, int speed)
	{
		WORD MyAttribTrain = FOREGROUND_BLUE | BLUE_FONT | FOREGROUND_INTENSITY;
		WORD MyAttribRails = 15 + 0;
		WORD MyAttribRails1 = 15 + 0;

		COORD coord;
		coord.X = x;
		coord.Y = y;
		LPDWORD N = 0;

		if(x == 35)// направление движения сверху -> вниз
		{
	for(int i = 0; i < 26; i++)
	{
		coord.Y = i;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
		Sleep(speed * 1.5);
		--coord.Y;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		if(i == 12)
		{
			coord.Y = i - 1;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
			Sleep(1000);//остановка
		}
		coord.Y = i - 1;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
	}

	int j = 35; 

		for(int i = 26; i < 73	; i++)
		{
			j++;
			coord.Y = i;
			coord.X = j;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
		Sleep(speed * 1.5);
		--coord.Y;
		--coord.X;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsX1,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		}
		coord.Y = 72;
		coord.X = 82;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsX1,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		

		for(int j = 84; j < 135; j++)
		{
			coord.X = j;
			coord.Y = 72;
			
		WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
		Sleep(speed * 1.5);
		--coord.X;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		
			if(j == 108)
			{
				coord.X = j - 1;
				WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
				WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
				Sleep(4000);//остановка
			}
			coord.X = j - 1;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		}
		coord.X = 134;
		coord.Y = 72;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);


		for(int j = 74; j < 230; j++)
		{
			coord.X = 135;
			coord.Y = j;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
			Sleep(speed * 1.5);
			--coord.Y;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
			if(j == 100 || j == 158 || j == 229)
			{
				coord.Y = j - 1;
				WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
				WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
				Sleep(1000);//остановка
			}
			coord.Y = j - 1;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		}
		coord.X = 135;
		coord.Y = 229;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		}
		else
			if(x == 36) // направление движения снизу -> вверх
			{
				int j = 228; 

				for(int j = 228; j > 71; j--)
		{
			coord.X = 136;
			coord.Y = j;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
			Sleep(speed * 1.5);
			++coord.Y;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
			if(j == 100 || j == 158 || j == 229)
			{
				coord.Y = j + 1;
				WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
				WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
				Sleep(4000);//остановка
			}
			coord.Y = j + 1;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		}
			coord.X = 136;
			coord.Y = 72;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);

		for(int j = 134; j > 82; j--)
		{
			coord.X = j;
			coord.Y = 71;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
			Sleep(speed);
			++coord.X;

			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
			if(j == 108)
			{
				coord.X = j + 1;
				WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
				WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
				Sleep(5000);//остановка
			}
			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		}
			coord.X = 83;
			coord.Y = 71;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);

		j = 82;
		for(int i = 70; i > 24	; i--)
		{
			j--;
			coord.X = j;
			coord.Y = i;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
			Sleep(speed * 1.5);
			++coord.X;
			++coord.Y;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsX1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		}
			coord.X = 36;
			coord.Y = 25;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsX1,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);

		for(int i = 23; i > -1; i--)
	{
		coord.Y = i;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
		Sleep(speed * 1.5);

		++coord.Y;

		WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
		if(i == 12)
		{
			coord.Y = i + 1;
			WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
			WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
			Sleep(5000);//остановка
		}
		WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
	}
		coord.X = 36;
		coord.Y = 0;
		WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
		WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
			}
			//////////////Вторая ветка//////////////////
			else
			if(x == 26)// направление движения снизу -> вверх
			{
				for(int i = 238; i > 188; --i)
				{
					coord.X = 26;
					coord.Y = i;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);

					++coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(26,189,Povorot2,MyAttribRails1,1); // "╔"
				for(int i = 28; i < 68; ++i)
				{
					coord.Y = 189;
					coord.X = i;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed);

					--coord.X;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(67,189,Povorot1,MyAttribRails1,1); // "╝"
				for(int i = 187;i > 127; i--)
				{
					coord.Y = i;
					coord.X = 67;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);
					++coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
					if(i == 169)
				{
					coord.Y = i - 1;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(1000);//остановка
				}
				}
				WriteChars(67,128,Povorot,MyAttribRails1,1); // "╗"
				for(int i = 65; i > 25; --i)
				{
					coord.X = i;
					coord.Y = 128;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed);

					++coord.X;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);					
				}
				WriteChars(26,128,Povorot3,MyAttribRails1,1); // "╚"
				for(int i = 126;i > 94; i--)
				{
					coord.Y = i;
					coord.X = 26;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);
					++coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
					if(i == 109)
				{
					coord.Y = i - 1;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(1000);//остановка
				}
				}
				WriteChars(26,95,Povorot2,MyAttribRails1,1); // "╔"
				for(int i = 28; i  < 95; i++)
				{
					coord.X = i;
					coord.Y = 95;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed);

					--coord.X;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(94,95,Povorot1,MyAttribRails1,1); // "╝"
				for(int i = 93;i > 83; i--)
				{
					coord.Y = i;
					coord.X = 94;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);
					++coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(94,84,RailsV1,MyAttribRails1,1); // "╫"; //вертикальные рельсы
				Sleep(10000); // остановка под Central Station
				for(int i = 58;i > 29; i--)
				{
					coord.Y = i;
					coord.X = 94;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);
					++coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(94,30,Povorot2,MyAttribRails1,1); // "╔"
				for(int i = 96; i  < 155; i++)
				{
					coord.X = i;
					coord.Y = 30;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed);

					--coord.X;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(154,30,Povorot1,MyAttribRails1,1); // "╝"
				for(int i = 28;i > 10; i--)
				{
					coord.Y = i;
					coord.X = 154;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);
					++coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				Sleep(10000); // конечная остановка
				WriteChars(154,11,RailsV1,MyAttribRails1,1); // "╫"; //вертикальные рельсы
			}
			else
			if(x == 25)// направление движения cверху -> вниз  
			{
				for(int i = 12;i < 30; i++)
				{
					coord.Y = i;
					coord.X = 153;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);
					--coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(153,29,Povorot1,MyAttribRails1,1); // "╝"
				for(int i = 151; i  > 92; i--)
				{
					coord.X = i;
					coord.Y = 29;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed);

					++coord.X;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(93,29,Povorot2,MyAttribRails1,1); // "╔"
				for(int i = 31;i < 60; i++)
				{
					coord.Y = i;
					coord.X = 93;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);
					--coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(93,59,RailsV1,MyAttribRails1,1); // "╫"; //вертикальные рельсы
				Sleep(2000); // остановка на Central Station
				for(int i = 85;i < 95; i++)
				{
					coord.Y = i;
					coord.X = 93;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);
					--coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(93,94,Povorot1,MyAttribRails1,1); // "╝"
				for(int i = 91; i  > 24; i--)
				{
					coord.X = i;
					coord.Y = 94;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed);

					++coord.X;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(25,94,Povorot2,MyAttribRails1,1); // "╔"
				for(int i = 96;i < 130; i++)
				{
					coord.Y = i;
					coord.X = 25;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);
					--coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
					if(i == 109)
				{
					coord.Y = i + 1;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(1000);//остановка
				}
				}
				WriteChars(25,129,Povorot3,MyAttribRails1,1); // "╚"
				for(int i = 27; i < 67; ++i)
				{
					coord.X = i;
					coord.Y = 129;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed);

					--coord.X;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);					
				}
				WriteChars(66,129,Povorot,MyAttribRails1,1); // "╗"
				for(int i = 131;i < 189; i++)
				{
					coord.Y = i;
					coord.X = 66;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);
					--coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
					if(i == 169)
				{
					coord.Y = i + 1;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(1000);//остановка
				}
				}
				WriteChars(66,188,Povorot1,MyAttribRails1,1); // "╝"
				for(int i = 64; i > 24; --i)
				{
					coord.Y = 188;
					coord.X = i;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed);

					++coord.X;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsH1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				WriteChars(25,188,Povorot2,MyAttribRails1,1); // "╔"
				for(int i = 190; i < 240; ++i)
				{
					coord.X = 25;
					coord.Y = i;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)Vagon,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribTrain,1,coord,N);
					Sleep(speed * 1.5);

					--coord.Y;
					WriteConsoleOutputCharacterW(h,(LPCWSTR)RailsV1,1,coord,N);
					WriteConsoleOutputAttribute(h,&MyAttribRails,1,coord,N);
				}
				Sleep(10000); // конечная остановка
				WriteChars(25,239,RailsV1,MyAttribRails1,1); // "╫"; //вертикальные рельсы
			}
	}